var app = getApp();
Component({

    properties: {
    },
    data: {
        isshow : false,
        goodslist : [],
        shopid : 0,
    },
    options : {
        addGlobalClass : true,
    },
    methods: {
        selectgoods(e){
            var i = e.currentTarget.dataset.i;
            var item = this.data.goodslist[i];
            this.triggerEvent('selectgoods',item);
            this.setData({
                isshow : false,
            })
        },
        onClose(){
            this.setData({
                isshow : !this.data.isshow,
            })
        },
        showgoodsfn(shopid){
            var self = this;

            if(this.data.shopid == shopid && this.data.goodslist.length > 0){
                self.setData({
                    isshow : true,
                })
                return false;
            }
            this.data.shopid = shopid;
            var postdata = {
                op : 'findgoods',
                shopid : shopid,
            };
            if(!postdata.shopid){
                app.com.toast('先选择店铺');
                return false;
            }

            app.com.http('admin','POST',postdata,0,true,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        isshow : true,
                        goodslist : res.data.data.list,
                    })
                }else{
                    app.com.toast( res.data.message);
                }
            });
        },
    }

})